//
//  GHCommentTableViewCell.m
//  GodHorses
//
//  Created by Mac on 2017/11/18.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHCommentTableViewCell.h"
#import "NSDate+STFormatter.h"
@interface GHCommentTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;
@property(nonatomic, strong) STLabel                     *timeLable;
@property(nonatomic, strong) STLabel                     *commentLable;
@end
@implementation GHCommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
    self.iconImageView.layer.cornerRadius = 20;
    self.iconImageView.clipsToBounds = YES;
    [self addSubview:self.iconImageView];
    
    self.timeLable =  [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, 15, UIScreenWidth - 20 - self.iconImageView.st_right, 16)
                                                     text:@"--------"
                                                textColor:GH_secendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.timeLable];
    
    self.commentLable =  [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.timeLable.st_bottom + 5, UIScreenWidth - 20 - self.iconImageView.st_right, 40)
                                                text:@"--------"
                                           textColor:GH_firstTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.commentLable.numberOfLines = 0;
    [self addSubview:self.commentLable];
}
- (void)setModel:(GHCommentModel *)model{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.u_img] placeholderImage:GH_placeHoderImage];
    NSDate * date = [NSDate dateWithTimeIntervalSince1970:[model.add_time integerValue]].st_localDate;
    self.timeLable.text =  date.st_yyyyMMddhhmmssWithDate;
    self.commentLable.text = model.content;
    [NSString lableAutoAdjustheightWithLabel:self.commentLable];
    model.height = self.commentLable.st_bottom + 20;
}
@end
